package com.heima.wemedia.listener;

import com.heima.model.user.pojos.ApUser;
import com.heima.wemedia.service.WmUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

//@Component
@Slf4j
public class UserListener {
    @Autowired
    private WmUserService service;
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "ap_add_queue",durable = "true"),
            exchange = @Exchange(name = "ap_add_direct"),
            key = "ap_add"
    )
    )
    public void receiveUser(ApUser apUser){
        log.info("开始处理文章：{}",apUser);
        service.insert(apUser);
    }
}
